#ifndef __SPEEDDATA_
#define __SPEEDDATA_

#include <string>
#include <vector>

class SpeedPoint {
public:
    SpeedPoint() = default;
    ~SpeedPoint() = default;
    SpeedPoint(double s,double t,double v,double a,double da):s_(s),t_(t),v_(v),a_(a),da_(da) {}
    void set_s(double s) {s_ = s;}
    void set_v(double v) {v_ = v;}
    void set_t(double t) {t_ = t;}
    void set_a(double a) {a_ = a;}
    void set_da(double da) {da_ =da;}
    double s() const {return s_;}
    double t() const {return t_;}
    double v() const {return v_;}
    double a() const {return a_;}
    double da() const {return da_;}
    void Clear();

private:
    double s_ = 0.0;
    double t_ = 0.0;
    double v_ = 0.0;
    double a_ = 0.0;
    double da_ = 0.0;
};

class SpeedData : public std::vector<SpeedPoint> {
 public:
  SpeedData() = default;

  virtual ~SpeedData() = default;

  explicit SpeedData(std::vector<SpeedPoint> speed_points);

  void AppendSpeedPoint(const double s, const double time, const double v,
                        const double a, const double da);
  SpeedPoint ToSpeedPoint(const double s, const double t,
                                        const double v, const double a,
                                        const double da);
  double TotalTime() const;

  // Assuming spatial traversed distance is monotonous
  double TotalLength() const;

  bool EvaluateByTime(const double time,
                      SpeedPoint* const speed_point) const;

};

#endif //